import { post, get } from "./api.js";
import Qs from "qs";

export const imgUrl = "http://ybjh.xingive.com/ybjh";

//-----------------------------------------通用模块 -- 开始-----------------------------------------

// 通用图片上传
export const setUpload = (params) => {
  return post("/api/v1/common/upload", params, {
    headers: {
      "Content-Type": "multipart/form-data",
    },
  });
};

// 发送验证码
export const setSmsSend = (params) => {
  return get("/api/v1/sms/send", Qs.parse(params));
};

//-----------------------------------------通用模块 -- 结束-----------------------------------------

//-----------------------------------------新增接口 -- 开始-----------------------------------------

// 新增-是否可拍卖
export const buyStatus = (params) => {
  return post("/api/v1/base/info/buy/status", Qs.parse(params));
};

// 新增-用户卖出商品-投诉
export const saveComplaint = (params) => {
  return post("/api/v1/product/save/complaint", Qs.parse(params));
};

// 新增-上传充值凭证
export const infoRecharge = (params) => {
  return post("/api/v1/base/info/recharge", Qs.parse(params));
};

//-----------------------------------------新增接口 -- 结束-----------------------------------------

//-----------------------------------------登录/注册/找回密码模块 -- 开始-----------------------------------------

// 注册
export const setSignUp = (params) => {
  return post("/api/v1/sign/up/", Qs.parse(params));
};
// 登录
export const setSignIn = (params) => {
  return post("/api/v1/sign/in/", Qs.parse(params));
};
// 重置密码
export const setReset = (params) => {
  return post("/api/v1/reset/", Qs.parse(params));
};
//-----------------------------------------登录/注册/找回密码模块 -- 结束 -----------------------------------------

//-----------------------------------------我的模块 -- 开始-----------------------------------------

// 用户基本信息
export const getInfo = () => {
  return post("/api/v1/base/info/");
};

// 修改头像
export const setAvatar = (params) => {
  return post("/api/v1/base/info/change/avatar", Qs.parse(params));
};

// 修改用户名
export const setUserName = (params) => {
  return post("/api/v1/base/info/change/username", Qs.parse(params));
};

// 获取认证信息
export const getIdentity = (params) => {
  return post("/api/v1/base/info/get/identity", Qs.parse(params));
};

// 修改认证信息
export const setIdentity = (params) => {
  return post("/api/v1/base/info/save/identity", Qs.parse(params));
};

//-----------------------------------------我的模块 -- 结束-----------------------------------------

//-----------------------------------------首付款模块 -- 开始-----------------------------------------

// 获取收付款信息
export const getPayment = (params) => {
  return post("/api/v1/base/info/get/payment", Qs.parse(params));
};

// 保存收付款信息（微信，支付宝）
export const setPayment = (params) => {
  return post("/api/v1/base/info/save/payment", Qs.parse(params));
};

// 保存收付款信息银行卡
export const setPaymentCard = (params) => {
  return post("/api/v1/base/info/save/payment", Qs.parse(params));
};

//-----------------------------------------首付款模块 -- 结束-----------------------------------------

//-----------------------------------------收益明细模块 -- 开始-----------------------------------------

// 获取收益明细
export const getAccountList = (params) => {
  return post("/api/v1/base/info/account/list", Qs.parse(params));
};

// 提现
export const getWithdraw = (params) => {
  return post("/api/v1/base/info/account/withdraw", Qs.parse(params));
};

//-----------------------------------------收益明细模块 -- 结束-----------------------------------------

//-----------------------------------------团队信息模块 -- 开始-----------------------------------------

// 获取收益明细
export const getInfoTeam = (params) => {
  return post("/api/v1/base/info/team", Qs.parse(params));
};

//-----------------------------------------团队信息模块 -- 结束-----------------------------------------

//-----------------------------------------收货地址模块 -- 开始-----------------------------------------

// 获取收货地址列表
export const getAddressList = (params) => {
  return post("/api/v1/base/info//address/list", Qs.parse(params));
};

// 添加收货地址
export const addAddress = (params) => {
  return post("/api/v1/base/info/address/add", Qs.parse(params));
};

// 修改收货地址
export const setAddress = (params) => {
  return post("/api/v1/base/info/address/update", Qs.parse(params));
};

//-----------------------------------------收货地址模块 -- 结束-----------------------------------------

//-----------------------------------------协议模块 -- 开始-----------------------------------------

// 协议列表
export const getProtocolList = (params) => {
  return post("/api/v1/common/protocol/list", Qs.parse(params));
};

// 协议详情
export const getProtocoDetail = (params) => {
  return post("/api/v1/common/protocol/detail", Qs.parse(params));
};

//-----------------------------------------协议模块 -- 结束-----------------------------------------

//-----------------------------------------消息模块 -- 开始-----------------------------------------

// 消息分页列表
export const getNoticePage = (params) => {
  return post("/api/v1/base/info/notice/page", Qs.parse(params));
};

//-----------------------------------------消息模块 -- 结束-----------------------------------------

//-----------------------------------------首页模块 -- 开始-----------------------------------------

// banner图
export const getBannerList = () => {
  return post("/api/v1/common/banner/list");
};

// 公告列表
export const getAnnounceList = () => {
  return post("/api/v1/common/announce/list");
};

// 活动列表
export const getActiveList = () => {
  return post("/api/v1/common/active/list");
};

//-----------------------------------------首页模块 -- 结束-----------------------------------------

//-----------------------------------------商品模块 -- 开始-----------------------------------------

// 商品列表
export const getActivePage = (params) => {
  return post("/api/v1/product/active/page", Qs.parse(params));
};

// 商品列表详情
export const getActiveDetail = (params) => {
  return post("/api/v1/product/active/detail", Qs.parse(params));
};

//-----------------------------------------商品模块 -- 结束-----------------------------------------

//-----------------------------------------商品购买/支付/取消购买 模块 -- 开始-----------------------------------------

// 商品买入列表
export const getGoodsList = (params) => {
  return post("/api/v1/product/buy/page", Qs.parse(params));
};

// 购买商品
export const setProductBuy = (params) => {
  return post("/api/v1/product/buy", Qs.parse(params));
};

// 获取商品收付款信息
export const getProductPayment = (params) => {
  return post("/api/v1/product/payment", Qs.parse(params));
};

// 商品买入详情
export const getBuyDetail = (params) => {
  return post("/api/v1/product/buy/detail", Qs.parse(params));
};

// 上传付款凭证
export const getProductCert = (params) => {
  return post("/api/v1/product/upload/cert", Qs.parse(params));
};

// 取消购买
export const getProductCancel = (params) => {
  return post("/api/v1/product/cancel", Qs.parse(params));
};

//-----------------------------------------商品购买/支付/取消购买 模块 -- 结束-----------------------------------------

//-----------------------------------------卖出商品模块 -- 开始-----------------------------------------

// 卖出商品列表
export const getUserPage = (params) => {
  return post("/api/v1/product/user/page", Qs.parse(params));
};

// 卖出商品详情
export const getUserDetail = (params) => {
  return post("/api/v1/product/user/detail", Qs.parse(params));
};

// 上架商品审核（上传支付凭证）
export const getPostCert = (params) => {
  return post("/api/v1/product/upload/post/cert", Qs.parse(params));
};

// 检查是否可上架
export const getPostStatus = (params) => {
  return post("/api/v1/product/get/post/status", Qs.parse(params));
};

// 修改商品状态
export const getChangeStatus = (params) => {
  return post("/api/v1/product/change/status", Qs.parse(params));
};

// 查看买家支付凭证
export const getPayCert = (params) => {
  return post("/api/v1/product/get/pay/cert", Qs.parse(params));
};

// 确认收款
export const receiptCert = (params) => {
  return post("/api/v1/product/receipt/cert", Qs.parse(params));
};

// 获取上架收付款信息
export const postPayment = (params) => {
  return post("/api/v1/product/post/payment", Qs.parse(params));
};

//-----------------------------------------卖出商品模块 -- 结束-----------------------------------------
